<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Dotnet2-web 后台管理系统</title>
<!--[if lt IE 9]>
<script src="js/html5.js"></script>
<![endif]-->
<%@ include file="/jsp/common/commonJs.jsp"%>
</head>
<body>
	<!--header-->
	<%@ include file="/jsp/top.jsp"%>
	<!--header-->
	<!--aside nav-->
	<%@ include file="/jsp/left.jsp"%>
	<!--aside nav  -->
	<form id="update" method="post" action="${path}/field/updateField.do" >
		<input type="hidden" name="id" value="${productField.id}" />
		<input type="hidden" name="productId" value="${productField.productId}" />
		<section class="rt_wrap content mCustomScrollbar" style="margin-top: 10px;">
			 <div class="page_title">
		       <a class="fr top_rt_btn" href="javascript:js.back()">返回上一页</a>
		      </div>
			<ul class="ulColumn2">
				<li>
					<span class="item_name" style="width: 120px;">属性名称：</span> 
						<input type="text" name="fieldName" value="${productField.fieldName}" class="textbox textbox_295" datatype="*" errormsg="请填写产品名称"
						placeholder="请填写产品名称" /> <span class="Validform_checktip">
						</span>
				</li>
				<li>
					<span class="item_name" style="width: 120px;">表单name：</span> 
					<input type="text" name="inputName" value="${productField.inputName}" class="textbox textbox_295" datatype="*" errormsg="表单name不能为空" placeholder="表单name不能为空" />
				</li>
				<li>
					<span class="item_name" style="width: 160px;">是否参与价格计算：</span> 
					<label class="single_selection"><input type="radio" onclick="isSp()" ${productField.isSum=='1'?"checked":""} name="isSum" value="1"/>是</label>
					 <label class="single_selection"><input type="radio" onclick="isSp()" ${productField.isSum=='0'?"checked":""}  name="isSum" value="0"/>否</label>
				</li>
				<li id="isSp">
					<span class="item_name" style="width: 160px;">是否为特殊计价：</span>
					<label class="single_selection"><input type="radio" ${productField.isSpe=='1'?"checked":""} name="isSpe" value="1"/>是</label>
					<label class="single_selection"><input type="radio" ${productField.isSpe=='0'?"checked":""} name="isSpe" value="0"/>否</label>
				</li>
				<li id="isCheckboxChild">
					<span class="item_name" style="width: 160px;">是否为checkbox（复选框）子项：</span>
					<label class="single_selection"><input type="radio" ${productField.isCheckboxChild=='1'?"checked":""} name="isCheckboxChild" value="1"/>是</label>
					<label class="single_selection"><input type="radio" ${productField.isCheckboxChild=='0'?"checked":""} name="isCheckboxChild" value="0"/>否</label>
				</li>
				<li>
					<span class="item_name" style="width: 120px;">是否校验：</span> 
					<label class="single_selection"><input type="radio" onclick="isVd()" ${productField.isValidate=='1'?"checked":""} name="isValidate" value="1"/>是</label>
					<label class="single_selection"><input type="radio" onclick="isVd()" ${productField.isValidate=='0'?"checked":""} name="isValidate" value="0"/>否</label>
				</li>
				<li id="vdType">
					<span class="item_name" style="width: 120px;">校验类型：</span> 
					<label class="single_selection"><input type="radio" ${productField.validateType=='0'?"checked":""} name="validateType" value="0"/>不为空</label>
					<label class="single_selection"><input type="radio" ${productField.validateType=='1'?"checked":""} name="validateType" value="1"/>只能为汉字</label>
					<label class="single_selection"><input type="radio" ${productField.validateType=='2'?"checked":""} name="validateType" value="2"/>只能为数字</label>
				</li>
				<li id="error">
					<span class="item_name" style="width: 120px;">错误提示：</span>
					<input type="text" name="errorMsg" value="${productField.errorMsg}" class="textbox textbox_295" id="errorMsg" datatype="s2-20" errormsg="错误提示至少2个字符,最多20个字符！"
						placeholder="请填写错误提示" /> <span class="Validform_checktip">
				</li>
				<li>
					<span class="item_name" style="width: 120px;">表单提示：</span>
					<input type="text" name="inputMsg" value="${productField.inputMsg}" class="textbox textbox_295" datatype="s2-20" errormsg="表单提示至少2个字符,最多20个字符！"
						placeholder="请填写表单提示" /> <span class="Validform_checktip">
				</li>
				<li>
					<span class="item_name" style="width: 120px;">数据展示方式：</span> 
					 <select class="select" name="fieldType" datatype="*" errormsg="产品分类不能为空！">
				        <!--  <option value="">请选择</option> -->
				         <option value="text" <c:if test="${productField.fieldType=='text'}">selected</c:if> >text（文本框）</option>
				         <option value="radio" <c:if test="${productField.fieldType=='radio'}">selected</c:if> >radio（单选按钮）</option>
				         <option value="select" <c:if test="${productField.fieldType=='select'}">selected</c:if> >select（下拉框）</option>
				         <option value="textdate" <c:if test="${productField.fieldType=='textdate'}">selected</c:if> >text（日期格式）</option>
				         <option value="checkbox" <c:if test="${productField.fieldType=='checkbox'}">selected</c:if> >checkbox(复选框)</option>
				         <option value="hidden">hidden（隐藏域）</option>
			        </select>
				</li>
				<li>
					<span class="item_name" style="width: 120px;"></span> 
					 <input type="button" onclick="update()" value="保存" class="link_btn" />
				</li>
			</ul>
		</section>
	</form>
<!-- 表单校验 -->
<script>
var form=$("#update").Validform({
		tiptype:3
	});
/**
 * 是否特殊计价
 */
 var isSum='${productField.isSum}';
if(isSum=='1'){
	inputDisable('isSp','true');
}else{
	inputDisable('isSp','hide');
}
/**
 * 是否校验
 */
var isValidate='${productField.isValidate}';
if(isValidate=='1'){
	inputDisable('vdType','true');
	inputDisable('error','true');
}else{
	inputDisable('vdType','hide');
	inputDisable('error','hide');
}
/* $("#vdType").hide();
$("#error").hide();
$("#isSp").hide(); */
function inputDisable(liId,type){
	if('hide'==type){
		$("#"+liId+"").find("input").each(function(){
			$(this).attr("disabled","true");
			//获取input type属性
			var type=$(this).attr("type");
			if('text'==type){
				//获取input id属性
				var id=$(this).attr("id");
				//忽略该input 验证
				form.ignore("#"+id+"");
			}
		});
	}else{
		$("#"+liId+"").find("input").each(function(){
			$(this).removeAttr("disabled");
			//获取input type属性
			var type=$(this).attr("type");
			if('text'==type){
				//获取input id属性
				var id=$(this).attr("id");
				//不忽略该input 验证
				form.unignore("#"+id+"");
			}
		});
	}
}
//提交
 function validate() {
    if (confirm("是否保存?")) {
       return true;
    } else {
       return false;
    }
 }
 
 function update() {
    if (validate()) {
    	if(form.check()){
    		$("#update").submit();
    	}
    }
 }

function isSp(){
	var flag=$("input[name=isSum]:checked").val();
	if(flag==0){
		inputDisable('isSp','hide');
	}else{
		inputDisable('isSp','show');
	}
}
function isVd(){
	var flag = $("input[name=isValidate]:checked").val();
	if(flag==0){
		/* $("#vdType").hide();
		$("#error").hide(); */
		inputDisable('vdType','hide');
		inputDisable('error','hide');
	}else{
	/* 	$("#vdType").show();
		$("#error").show(); */
		inputDisable('vdType','show');
		inputDisable('error','show');
	} 
}
</script>
</body>
</html>